<?xml version='1.0' encoding='utf-8'?>
<%@page contentType="text/xml" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
    'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'>
<article lang="cs">
    <articleinfo>
        <title>Export příjmů a výdajů</title>
    </articleinfo>
    <section>
        <title>Export dat z aplikace PrVydEvW</title>
        <itemizedlist>
            <title>Filtry</title>
            <listitem>
                <para>Datum: 
                    <c:if test="${filterDateFrom != null}"><fmt:formatDate value="${filterDateFrom.time}" type="date" pattern="yyyy-MM-dd" /></c:if>
                        - 
                    <c:if test="${filterDateTo != null}"><fmt:formatDate value="${filterDateTo.time}" type="date" pattern="yyyy-MM-dd" /></c:if>
                </para>
            </listitem>
            <listitem>
                <para>Subjekt: <c:if test="${filterSubject != null}"><c:out value="${filterSubject}" /></c:if><c:if test="${filterSubject == null}">-</c:if></para>
            </listitem>
        </itemizedlist>
        <table>
            <title>Příjmy a výdaje</title>
            <tgroup cols="5">
                <colspec colname="date" />
                <colspec colname="id" />
                <colspec colname="subject" />
                <colspec colname="description" />
                <colspec colname="amount" />
                <thead>
                <row>
                    <entry>Datum</entry>
                    <entry>ID</entry>
                    <entry>Subjekt</entry>
                    <entry>Popis platby</entry>
                    <entry>Částka</entry>
                </row>
                </thead>
                <tbody>
                    <!-- It shouldn't be list, but map with payment and subject (or subject name only because nothing more from subject is used) --> 
                    <c:forEach items="${payments}" var="payment">
                    <row>
                        <entry><fmt:formatDate value="${payment.date.time}" type="date" dateStyle="short" /></entry>
                        <entry><c:out value="${payment.id}" /></entry>
                        <entry><c:out value="${subjects[payment.subjectID].name}" /></entry>
                        <entry><c:out value="${payment.description}" /></entry>
                        <entry><c:out value="${payment.amount}" /></entry>
                    </row>
                </c:forEach>
                <row>
                    <entry namest="date" nameend="description">Příjmy celkem</entry>
                    <entry><c:out value="${income}" /></entry>
                </row>
                <row>
                    <entry namest="date" nameend="description">Výdaje celkem</entry>
                    <entry><c:out value="${expenses}" /> </entry>
                </row>
                <row>
                    <entry namest="date" nameend="description">Součet</entry>
                    <entry><c:out value="${balance}" /> </entry>
                </row>
                </tbody>
            </tgroup>
        </table>
        
    </section>
</article>
